package com.terrace.core.utils.reflect;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

/**
 * 反射工具类
 * @author jiangyg
 *
 */
public class ReflectUtils {
	
	/**
	 * 
	 * @param methodName
	 * @param cls
	 * @param methods
	 * @param arguments
	 * @return
	 */
	public static <T extends Annotation> T obtainAnnotation(String methodName, Class<T> cls, Method[] methods, Object[] arguments) {
		T t = null;
		for (Method method : methods) {
			if (method.getName().equals(methodName)) {
				Class<?>[] tmpCs = method.getParameterTypes();
				if (tmpCs.length == arguments.length) {
					t = method.getAnnotation(cls);
					break;
				}
			}
		}
		return t;
	}

}